package com.xjc.infra.util;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;


/**
 *
 */
public class PageFrom {
    private static Logger logger = Logger.getLogger(PageFrom.class);

    /**
     * 组装返回视图地址
     * 
     * @param site
     *            jsp目录地址
     * @param strPage
     *            jsp名称
     * @return
     * @Description: site可以为空
     */
    public static String getView(String site, String strPage) {

        String strView = "";
        if (isNoNullOrEmpty(site)) {
            strView = site + "/";
        }
        strView = strView + strPage;
        return strView;
    }
    
    public static String getEntrustView(String site, String strPage) {

        String strView = "";
        if (isNoNullOrEmpty(site)) {
            strView = site + "/";
        }
        strView = strView + strPage;
        return "entrust/"+strView;
    }

    /**
     * 判断是否为空,实体类是否new
     * 
     * @param obj
     * @return false为空或“”或没new,true不为空或“”或已new
     * @Description: 不能判断实体类是否有值
     */
    public static boolean isNoNullOrEmpty(Object obj) {
        boolean bl = false;
        if (null != obj) {
            if (!obj.toString().equals("")) {
                bl = true;
            }
        }
        return bl;
    }

    /**
     * 判断是否为空,实体类是否new
     * 
     * @param obj
     * @return ture为空或“”或没new,false不为空或“”或已new
     * @Description: 不能判断实体类是否有值
     */
    public static boolean isNullOrEmpty(Object obj) {
        boolean bl = true;
        if (null != obj) {
            if (!obj.toString().equals("")) {
                bl = false;
            }
        }
        return bl;
    }

    /**
     * 判断字符串是否为空
     * 
     * @author peng
     * @param str
     * @return 空 true 非空 false
     */
    public static boolean isEmpty(String str) {
        if (str != null && !"".equals(str) && !"null".equals(str)) {
            return false;
        } else {
            return true;
        }
    }

    public static boolean isNull(Object obj) {
        if (isEmpty(String.valueOf(obj))) {
            return true;
        } else {
            return false;
        }
    }

    public static String addSlashes(String str) {
        str = str.replaceAll("'", "''"); // SQL-92标准
        // str = str.replaceAll("\"", "\\\\\"");
        return str;
    }

    /**
     * @author peng
     * @param obj
     * @return
     * @Description:判断是否是字符串数组
     */
    public static boolean isStringArr(Object obj) {
        if (obj instanceof String[]) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 获取时间
     * 
     * @param strFormat
     *            格式 如:"yyyy-MM-dd HH:mm:ss" 默认"yyyyMMddHHmmss"
     * @return
     * @Description:
     */
    public static String getDateFormat(String strFormat) {
        if (!isNoNullOrEmpty(strFormat)) {
            strFormat = "yyyyMMddHHmmss";
        }
        SimpleDateFormat df = new SimpleDateFormat(strFormat);// 设置日期格式
        return df.format(new Date());// new Date()为获取当前系统时间
    }

    /**
     * 获取时间
     * 
     * @param strFormat
     *            格式 如:"yyyy-MM-dd HH:mm:ss" 默认"yyyyMMddHHmmss"
     * @return
     * @Description:
     */
    public static Date getDateFormat(String date, String strFormat) {
        if (!isNoNullOrEmpty(strFormat)) {
            strFormat = "yyyyMMddHHmmss";
        }
        Date newDate = null;
        SimpleDateFormat df = new SimpleDateFormat(strFormat);// 设置日期格式
        try {
            newDate = df.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return newDate;
    }

    public static String maintainDate(Date date, String strFormat, boolean flag) {
        SimpleDateFormat sf = new SimpleDateFormat(strFormat);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        if (flag) {
            calendar.add(Calendar.DATE, 1);
        }
        Date newDate = new Date(calendar.getTimeInMillis());
        return sf.format(newDate);
    }

    /**
     * oPConversionTimeFormat Date 时间转String
     * 
     * @param date
     * @param strFormat
     *            格式 如:"yyyy-MM-dd HH:mm:ss" 默认"yyyyMMddHHmmss"
     * @return String
     * @exception
     * @since 1.0.0
     */
    public static String oPConversionTimeFormat(Date date, String strFormat) {
        String strDate = "";
        if (!isNoNullOrEmpty(strFormat)) {
            strFormat = "yyyyMMddHHmmss";
        }
        SimpleDateFormat df = new SimpleDateFormat(strFormat);// 设置日期格式
        strDate = df.format(date);
        return strDate;
    }

    /**
     * 给当前时间添加小时
     * 
     * @param min
     *            需要添加小时
     * @return
     */
    public static long getAddHour(int hour) {
        long time = System.currentTimeMillis();
        Date date = new Date(time);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.HOUR, hour);
        return calendar.getTimeInMillis();
    }
    /**
     * 给当前时间添加小时
     * 
     * @param min
     *            需要添加小时
     * @return
     */
    public static long getAddMin(int min) {
        long time = System.currentTimeMillis();
        Date date = new Date(time);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.add(Calendar.MINUTE, min);
        return calendar.getTimeInMillis();
    }
    /**
     * 旧时间格式转换新时间格式
     * 
     * @param eDate
     *            时间
     * @param strOldFormat
     *            旧格式默认 "yyyyMMddHHmmss"
     * @param strNewFormat
     *            新格式
     * @return
     * @Description:
     */
    public static String oPConversionTimeFormat(String eDate, String strOldFormat, String strNewFormat) {
        String strDate = "";
        if (!isNoNullOrEmpty(strOldFormat)) {
            strOldFormat = "yyyyMMddHHmmss";
        }
        try {
            SimpleDateFormat formatter = new SimpleDateFormat(strOldFormat);
            Date edate = formatter.parse(eDate);
            SimpleDateFormat df = new SimpleDateFormat(strNewFormat);// 设置日期格式
            strDate = df.format(edate);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return strDate;
    }

    /**
     * 获取随机数
     * 
     * @param digit
     *            获取多少位
     * @return
     * @Description:
     */
    public static String getRandom(int digit) {
        String strSJ = "";
        Random r = new Random();
        for (int i = 0; i < digit; i++) {
            strSJ = strSJ + r.nextInt(9);

        }
        return strSJ;
    }

    /**
     * ajax返回json
     * 
     * @param response
     * @param obj
     *            返回消息
     */
    public static void jsonResponseWriter(Object obj, HttpServletResponse response) {
        try {
            response.setContentType("text/text;charset=UTF-8");
            response.getWriter().print(JsonUtil.toJson(obj));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    /**
     * 将对象写入输出流水
     * @author liangcz
     * @date   2018年1月21日 上午10:51:43
     * @return void
     */
    public static void jsonResponseWriter(Object obj) {
        try {
        	HttpServletResponse response = ServletUtil.getHttpServletResponse();
            response.setContentType("text/text;charset=UTF-8");
            response.getWriter().print(JsonUtil.toJson(obj));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


  

    /**
     * 
     * String 转 BigDecimal
     * 
     * @param v1
     * 
     * 
     * @return 两个参数 BigDecimal
     */

    public static BigDecimal StringOrBigDecimal(String v1) {
        BigDecimal b1 = new BigDecimal(v1);
        return b1;
    }

    /**
     * 
     * 提供精确的加法运算。
     * 
     * @param v1
     * 
     * @param v2
     * 
     * @return 两个参数的和
     */

    public static String BigDecimalAdd(String v1, String v2) {
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.add(b2).toString();

    }

    /**
     * 
     * 提供精确的减法运算
     * 
     * @param v1
     * 
     * @param v2
     * 
     * @return 两个参数数学差，以字符串格式返回
     */
    public static String BigDecimalSubtract(String v1, String v2) {
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.subtract(b2).toString();

    }

    /**
     * 提供精确的乘法运算。
     * 
     * @param v1
     * @param v2
     * @return 两个参数的积
     */
    public static String BigDecimalMultiply(String v1, String v2) {
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.multiply(b2).toString();
    }

    /**
     * 乘法运算后保留指定的小数位
     * 
     * @param v1
     * @param v2
     * @param mode
     *            获取SystemConstant ROUND_XXX 指定的舍入模式
     * @return
     */
    public static String BigDecimalMultiply(String v1, String v2, int scale, int mode) {
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.multiply(b2).setScale(scale, mode).toString();
    }

    /**
     * 
     * 提供（相对）精确的除法运算。当发生除不尽的情况时，由scale参数指 定精度，以后的数字四舍五入。舍入模式采用会员指定舍入模式
     * 
     * @param v1
     * @param v2
     * @param scale
     *            表示需要精确到小数点以后几位
     * @param round_mode
     *            获取SystemConstant ROUND_XXX 指定的舍入模式
     * @return 两个参数的商
     */
    public static String BigDecimalDivide(String v1, String v2, int scale, int round_mode) {
        if (scale < 0) {
            throw new IllegalArgumentException("必须是一个正整数或零");
        }

        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.divide(b2, scale, round_mode).toString();

    }

    /**
     * 返回空字符串
     * 
     * @param str
     * @return
     */
    public static String toNull(Object str) {
        if (isEmpty(String.valueOf(str))) {
            return "";
        } else {
            return String.valueOf(str);
        }
    }

    public static Map<String, String> mapForSelect(String type, HttpServletRequest request) {
        ServletContext application = request.getSession().getServletContext();
        Map<String, String> retMap = new TreeMap<String, String>();
        Map appMap = (Map) application.getAttribute("selApp");
        if (isNullOrEmpty(appMap)) {
            retMap = mapSortByKey((Map<String, String>) appMap.get(type));
            return retMap;
        }
        return null;
    }

    public static SortedMap<String, String> mapSortByKey(Map<String, String> unsort_map) {
        TreeMap<String, String> result = new TreeMap<String, String>();

        Object[] unsort_key = unsort_map.keySet().toArray();
        Arrays.sort(unsort_key);

        for (int i = 0; i < unsort_key.length; i++) {
            result.put(unsort_key[i].toString(), unsort_map.get(unsort_key[i]));
        }
        return result.tailMap(result.firstKey());
    }

    /**
     * 小写金额转大写金额
     * 
     * @param strv
     *            金额
     * @return
     */
    public static String change(String strv) {
        String UNIT = "万千佰拾亿千佰拾万千佰拾元角分";
        String DIGIT = "零壹贰叁肆伍陆柒捌玖";
        double MAX_VALUE = 9999999999999.99D;
        double v = Double.parseDouble(strv);

        if (v < 0 || v > MAX_VALUE)
            return "参数非法!";
        long l = Math.round(v * 100);
        if (l == 0)
            return "零元整";
        String strValue = l + "";
        // i用来控制数
        int i = 0;
        // j用来控制单位
        int j = UNIT.length() - strValue.length();
        String rs = "";
        boolean isZero = false;
        for (; i < strValue.length(); i++, j++) {
            char ch = strValue.charAt(i);

            if (ch == '0') {
                isZero = true;
                if (UNIT.charAt(j) == '亿' || UNIT.charAt(j) == '万' || UNIT.charAt(j) == '元') {
                    rs = rs + UNIT.charAt(j);
                    isZero = false;
                }
            } else {
                if (isZero) {
                    rs = rs + "零";
                    isZero = false;
                }
                rs = rs + DIGIT.charAt(ch - '0') + UNIT.charAt(j);
            }
        }

        if (!rs.endsWith("分")) {
            rs = rs + "整";
        }
        rs = rs.replaceAll("亿万", "亿");
        return rs;
    }

    /**
     * 添加字符串只获取前三位，后面忽略
     * 
     * @param value
     * @return
     */
    public static void exchangeString(String value) {
        String x = "************************************";
        value = value.substring(0, 3) + x.substring(3, value.length());
    }

    public static String exchangeStringLast3(String value) {
        String x = "************************************";
        value = value.substring(0, 1) + "****" + value.substring(value.length() - 1, value.length());
        return value;
    }

   

    /**
     * 判断验证码设置时间
     * 
     * @param request
     * @return boolean ture超过90秒
     */
    public static boolean getHeneym(HttpServletRequest request, String cmd) {
        boolean bl = true;
        if (isNoNullOrEmpty(request.getSession().getAttribute("heneym" + cmd))) {
            String dt = request.getSession().getAttribute("heneym" + cmd).toString();
            String newdt = getDateFormat("yyyy-MM-dd HH:mm:ss");
            try {
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式

                long diff = df.parse(newdt).getTime() - df.parse(dt).getTime();
                // long nd = 1000 * 24 * 60 * 60;// 一天的毫秒
                // long nh = 1000 * 60 * 60;// 一小时的毫秒
                // long nm = 1000 * 60;// 一分钟的毫秒a b
                long ns = 1000;// 一秒的毫秒
                long sec = 0;
                sec = diff / ns;
                if (sec < 90) {
                    bl = false;
                }
            } catch (ParseException e) {
                bl = true;
            }

        }
        if (bl) {
            request.getSession().setAttribute("heneym" + cmd, getDateFormat("yyyy-MM-dd HH:mm:ss"));
        }

        return bl;

    }

    /**
     * 删除 Session 超过90秒
     * 
     * @param request
     */
    public static void delHeneym(HttpServletRequest request, String cmd) {
        if (isNoNullOrEmpty(request.getSession().getAttribute("heneym" + cmd))) {
            request.getSession().removeAttribute("heneym" + cmd);
        }
    }

    /**
     * 添加字符串只获取前五位，后面忽略
     * 
     * @param value
     * @return
     */

    public static String exchangeStringLast4(String value) {
        String x = "...";
        value = value.substring(0, 5) + x;
        return value;
    }

    /**
     * 获取ip
     * 
     * @param request
     * @return ip
     */
    public static String getRemoteAddress(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown"))
            ip = request.getHeader("Proxy-Client-IP");
        if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown"))
            ip = request.getHeader("WL-Proxy-Client-IP");
        if (ip == null || ip.length() == 0 || ip.equalsIgnoreCase("unknown"))
            ip = request.getRemoteAddr();
        if(PageFrom.isNoNullOrEmpty(ip)&& ip.contains(",")){
            int index = ip.indexOf(",");
            ip = ip.substring(0, index);
        }
        return ip;
    }

    /**
     * 验证后台输入网址是否加上http协议
     * 
     * @param value
     * @return
     */
    public static String charat(String value) {
        String valStr = value.substring(0, 7);
        if (!valStr.equals("http://")) {
            value = "http://" + value;
        }
        return value;
    }

    /**
     * 金额转换千位显示
     * 
     * @return
     */
    public static String StringValueByDouble(Double value) {
        NumberFormat nf = new DecimalFormat(",###.00");
        return nf.format(value);
    }

    /**
     * 预览合同 打开流
     * 
     * 
     * 
     */
    public static void viewContract(HttpServletRequest request, HttpServletResponse response, String strURL) {
        String path = request.getSession().getServletContext().getRealPath("/");
		if(strURL.endsWith(".html")||strURL.endsWith(".htm"))
		{
			response.setContentType("text/html");
		}
		else
		{	
		   response.setContentType("application/pdf");
		}

        path = strURL;

        File file = new File(strURL);
        long fileLength = file.length();
        java.io.BufferedInputStream bis = null;
        java.io.BufferedOutputStream bos = null;

        response.setHeader("Content-Length", String.valueOf(fileLength));
        try {
            bis = new BufferedInputStream(new FileInputStream(path));
            bos = new BufferedOutputStream(response.getOutputStream());
            byte[] buff = new byte[2048];
            int bytesRead;
            while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                bos.write(buff, 0, bytesRead);
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (bis != null)
                try {
                    bis.close();
                } catch (IOException e1) {
                    logger.error("IOException错误Ae1：", e1);
                }
            if (bos != null)
                try {
                    bos.close();
                } catch (IOException e) {
                    logger.error("IOException错误B：", e);
                }
        }
    }

    /**
     * Double获取后缀小数为0则减除
     * 
     * @param value
     * @return
     */
    public static String getDecimalForMatDouble(Double value) {
        DecimalFormat df = new DecimalFormat("####.##");
        return df.format(value);
    }

    /**
     * 首页需要的日期类型
     * 
     * @param date
     * @return
     */
    public static String getIndexDate(Date date) {
        SimpleDateFormat sf = new SimpleDateFormat("M月d日H:mm发布");
        return sf.format(date);
    }

  
    /**
     * 是否邮箱
     * @param email
     * @return
     */
    public static boolean checkEmail(String email) {
        boolean flag = false;
        try {
        	String check = "^([a-z0-9A-Z]+[-|\\._]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
            Pattern regex = Pattern.compile(check);
            Matcher matcher = regex.matcher(email);
            flag = matcher.matches();
        } catch (Exception e) {
            flag = false;
        }

        return flag;
    }
    /**
     * 是否手机号码
     * @param mobiles
     * @return
     */
    public static boolean isMobileNO(String mobiles) {
        boolean flag = false;
        try {
            Pattern p = Pattern.compile("^((13[0-9])|(17[0-9])|(15[^4,\\D])|(18[0-9]))\\d{8}$");
            Matcher m = p.matcher(mobiles);
            flag = m.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }
    /**
     * 公司名字是否合法
     * @param companyName
     * @return
     */
    public static boolean isCompanyName(String companyName) {
        boolean flag = false;
        try {
            Pattern p = Pattern.compile("^([A-Za-z]|[\u4E00-\u9FA5]|[（）]|[0-9]){6,40}$");
            Matcher m = p.matcher(companyName);
            flag = m.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }
    public static String getRandomString(int length){  
        String str="0123456789";  
        Random random = new Random();  
        StringBuffer sb = new StringBuffer();  
          
        for(int i = 0 ; i < length; ++i){  
            int number = random.nextInt(10);//[0,62)  
              
            sb.append(str.charAt(number));  
        }  
        return sb.toString();  
    }  
    /**
     * 银行卡号  纯数字
     * @param companyName
     * @return
     */
    public static boolean isBankAccountNo(String companyName) {
        boolean flag = false;
        try {
            Pattern p = Pattern.compile("^\\d{1,20}$");
            Matcher m = p.matcher(companyName);
            flag = m.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }
    /**
     * 法人姓名
     * @param companyName
     * @return
     */
    public static boolean isChineseName(String companyName) {
        boolean flag = false;
        try {
            Pattern p = Pattern.compile("^[\u4E00-\u9FA5]{2,8}(?:·[\u4E00-\u9FA5]{2,8})*$");
            Matcher m = p.matcher(companyName);
            flag = m.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;
    }
    /**
     * 营业自找号
     * @param busCode
     * @return
     */
    public static boolean isEdBusNo(String busCode) {
//        boolean ret=false;
//        if(busCode!=null && busCode.length()==15)
//        { 
//            int[] s = new int[16];
//            int[] p = new int[16];
//            int[] a = new int[16];
//            int m =10;
//            p[0]=m;
//             for(int i=0;i<busCode.length();i++)
//              {
//                a[i]=Integer.parseInt(busCode.substring(i,i+1));
//                s[i]=(p[i]%(m+1))+a[i];
//                if(0==s[i]%m)
//                 {
//                    p[i+1]=10*2;
//                 }
//                else
//                {
//                    p[i+1] =(s[i]%m)*2;
//                }   
//              }
//             if(1==(s[14]%m))
//             {
//                 ret =true;
//             } 
//             else
//             {
//                 ret = false;
//             }       
//        } 
//        else if(""==busCode)
//       {
//            ret =true;
//       }    
        return true;
            
    }
    
    /**
     * @Describe 检验组织结构代码是否合法<br>
     *           标准:GB11714-1995
     * @since Monlyu 2009-1-11
     */
    public static boolean checkOrgCode(String str) {
        final String[] codeNo = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
                "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "O", "P", "Q", "R", "S",
                "T", "U", "V", "W", "X", "Y", "Z" };
        final String[] staVal = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11",
                "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
                "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35" };
        Map map = new HashMap();
        for (int i = 0; i < codeNo.length; i++) {
            map.put(codeNo[i], staVal[i]);
        }
        final int[] wi = { 3, 7, 9, 10, 5, 8, 4, 2 };
        Pattern pat = Pattern.compile("^[0-9A-Z]{8}-[0-9X]$");
        Matcher matcher = pat.matcher(str);
        if (!matcher.matches()) {
            return false;
        }
        String[] all = str.split("-");
        final char[] values = all[0].toCharArray();
        int parity = 0;
        for (int i = 0; i < values.length; i++) {
            final String val = Character.toString(values[i]);
            parity += wi[i] * Integer.parseInt(map.get(val).toString());
        }
        String cheak = (11 - parity % 11) == 10 ? "X" : Integer.toString((11 - parity % 11));
        return cheak.equals(all[1]);
    }
    
    //begin modify by dengxq 2017-06-14 
    /**
     * 判断验证码设置时间
     * 
     * @param request
     * @return boolean ture超过90秒
     */
    public static boolean hasHeneym(HttpServletRequest request, String cmd) {
        boolean bl = true;
        if (isNoNullOrEmpty(request.getSession().getAttribute("heneym" + cmd))) {
            String dt = request.getSession().getAttribute("heneym" + cmd).toString();
            String newdt = getDateFormat("yyyy-MM-dd HH:mm:ss");
            try {
                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置日期格式
                long diff = df.parse(newdt).getTime() - df.parse(dt).getTime();
                // long nd = 1000 * 24 * 60 * 60;// 一天的毫秒
                // long nh = 1000 * 60 * 60;// 一小时的毫秒
                // long nm = 1000 * 60;// 一分钟的毫秒a b
                long ns = 1000;// 一秒的毫秒
                long sec = 0;
                sec = diff / ns;
                if (sec < 90) {
                    bl = false;
                }
            } catch (ParseException e) {
                bl = true;
            }

        }
        
        return bl;

    }
    
  //End modify by dengxq 2017-06-14 

}
